package it.infodea.tapestrydea.services.jwindows.impl;


import it.infodea.tapestrydea.services.jwindows.JsWindowsThemesAssetsProvider;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.tapestry5.Asset;

public class JsWindowsThemesAssetsProviderImpl implements
		JsWindowsThemesAssetsProvider {

	private Map<String, Asset[]> assetsMap;
	private List<String> themes;
	private String defaultTheme;
	
	public JsWindowsThemesAssetsProviderImpl(Map<String, Asset[]> assetsMap, String defaultTheme) {
		super();
		this.assetsMap = assetsMap;
		this.themes = new ArrayList<String>(assetsMap.keySet());
		this.defaultTheme = defaultTheme;
	}

	public Asset[] provideAssets(String theme) {
		Asset[] assets = assetsMap.get(theme);
		return assets != null ? assets : assetsMap.get(defaultTheme);
	}

	public String[] provideThemes() {
		return themes.toArray(new String[]{});
	}

}
